package controllers

import (
	"fmt"
	"github.com/astaxie/beego/orm"
	_ "github.com/go-sql-driver/mysql"
	"ming/models"
)

type IndexController struct {
	MainController
}

func (c *IndexController) Get() {
	fmt.Println("123")
	c.Data["Website"] = "beego.me"
	c.Data["Email"] = "astaxie@gmail.com"
	c.TplName = "index.tpl"
}

func (c *IndexController) Index() {
	o := orm.NewOrm()

	art := models.Art{ArtName: "红色餐布"}

	err := o.Read(&art, "art_name")

	if err == orm.ErrNoRows {
		fmt.Println("查询不到")
	} else {
		fmt.Println(art.ArtName)
	}

	c.TplName = "index.tpl"
}
